<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="../assets/js/vue.js"></script>
    <title>v-on</title>
</head>
<body>
    <h1>v-on</h1>
    <hr>
    <div id="app">
        <div ><span>{{count}}</span>分数</div>
        <h3>v-on 方式绑定事件</h3>
        <button v-on:click="jia">加分</button>
        <button v-on:click="jian">减分</button>
        <h3>@ 方式绑定事件</h3>
        <button @click="jia">加分</button>
        <button @click="jian">减分</button>
        <h3>v-on 绑定键盘事件    按enter键加分</h3>
        <h2>加分<span>{{count}}</span></h2>
        <hr>
        <input type="text" v-on:keyup.enter="onEnter" v-model="secondCount">
    </div>
</body>
<script>
    var app = new Vue({
            el:"#app",
            data:{
                count:1,
                secondCount:10,
            },
            methods:{
                jia:function(){
                    this.count++;
                },
                jian:function(){
                    this.count--;
                    if(this.count-- <= 0){
                        this.count = 0;
                    }
                },
                onEnter:function(){
                    this.count = parseInt(this.secondCount) + this.count;
                }
            }

        })
</script>
</html>